﻿using Microsoft.Xaml.Behaviors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace MachineVision.Core.Util.Navigation
{
    public class ClickToNavigateBehavior : Behavior<Button>
    {
        public string TargetRegionName
        {
            get { return (string)GetValue(TargetRegionNameProperty); }
            set { SetValue(TargetRegionNameProperty, value); }
        }
        public static readonly DependencyProperty TargetRegionNameProperty =
            DependencyProperty.Register("TargetRegionName", typeof(string), typeof(ClickToNavigateBehavior));


        public string TargetViewName
        {
            get { return (string)GetValue(TargetViewNameProperty); }
            set { SetValue(TargetViewNameProperty, value); }
        }
        public static readonly DependencyProperty TargetViewNameProperty =
            DependencyProperty.Register("TargetViewName", typeof(string), typeof(ClickToNavigateBehavior));

        protected override void OnAttached()
        {
            base.OnAttached();
            AssociatedObject.Click += AssociatedObject_Click;
        }

        private void AssociatedObject_Click(object sender, RoutedEventArgs e)
        {
            CommonTool.Navigate(TargetRegionName, TargetViewName);
        }
    }
}